// 理解课上在GCC平台验证虚表的方式，以此为参考，验证一下虚表在内存中的哪个区域

#include <iostream>
using namespace std;
typedef void(*func)(void);

class Base
{
public:
    virtual void a(void) const{ cout << "Base::a" << endl;}
    virtual void b(void) const{ cout << "Base::b" << endl;}
    virtual void c(void) const{ cout << "Base::c" << endl;}
private:
    size_t _x = 10086;
};


class Derived
    : public Base
{
public:

private:
    size_t _y = 8080;
};

void fun(){
}
static size_t i = 10;

int main()
{
    Derived D;
    Derived* DD = new Derived ();
    size_t* arr = (size_t*)&D;
    
    printf("栈区: %p\n", &D);
    printf("堆区: %p\n", DD);
    printf("静态区: %p\n", &i);
    printf("虚函数表区: %p\n", (void*)arr[0]);
    printf("文字常量区: %p\n", "huzhu");
    printf("程序代码区: %p\n", &fun);
    cout << (void*)&fun << endl;
    
    return 0;
}
//       栈区: 0x7ffc4b5e3f80
//       堆区: 0x5640ebb44eb0
//     静态区: 0x5640eacdd010
// 虚函数表区: 0x5640eacdcd10
// 文字常量区: 0x5640eacdb058
// 程序代码区: 0x5640eacda209